package team.bluepen.supermarket.data.dao.abstraction;

import team.bluepen.supermarket.constant.Error;
import team.bluepen.supermarket.data.entity.HbaseItem;
import team.bluepen.supermarket.data.entity.Qualify;

import java.io.IOException;
import java.util.List;

/**
 * 存储库抽象类
 * @author Kai
 */
public abstract class Repository<T extends HbaseItem<T>> {
    private static final String TAG = "Repository";
    protected final DatabaseInterface<T> database;

    protected Repository(DatabaseInterface<T> database) {
        this.database = database;
    }

    public Error insert(String family, String row,
                       String qualifier , String value) {
        return database.insert(family, row, qualifier, value);
    }

    public Error insert(T t) {
        return database.insert(t);
    }

    public Error insert(List<T> t) {
        return database.insert(t);
    }

    public Error delete() {
        return database.delete();
    }

    public Error delete(String row) {
        return database.delete(row);
    }

    public Error delete(T t) {
        return database.delete(t);
    }

    public Error delete(List<T> t) {
        return database.delete(t);
    }

    public Error delete(String row, String family) {
        return database.delete(row, family);
    }

    public List<T> query() throws IOException {
        return database.query();
    }

    public T query(String row) throws IOException {
        return database.query(row);
    }

    public List<T> query(List<String> rows) throws IOException {
                return database.query(rows);
    }

    public List<T> query(String family, String qualifier,
                      byte[] value) throws IOException {
        return database.query(family, qualifier, value);
    }

    public List<T> query(Qualify qualify) throws IOException {
        return database.query(qualify);
    }

    public List<T> multiQuery(List<Qualify> qualifies) throws IOException {
        return database.multiQuery(qualifies);
    }

}
